package com.fary.resource;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

import java.io.IOException;
import java.io.InputStream;

public class TestClassPathResource {

	public static void main(String[] args) throws IOException {
		Resource resource = new ClassPathResource("beans.xml");
		String fileName = resource.getFilename();
		System.out.println(fileName);
		resource.getFile();   //获取资源对应的文件
		resource.getURL(); //获取资源对应的URL
		if (resource.isReadable()) {
			//每次都会打开一个新的流
			InputStream is = resource.getInputStream();
			PrintResource.printContent(is);
		}
	}
}
